package com.chinanet.netelementmodel;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chinanet.entry.netelement.Attr;
import com.chinanet.entry.netelement.AttrType;
import com.chinanet.entry.netelement.WorkInterFace;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.lang.StringUtils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * 资源查询网元能力
 * 思路：构建表单提交到原monitor系统，查询数据
 * Created by moon on 2016/12/6.
 */
public class RES_POST_SCANNER implements WorkInterFace {
    //private static final String RES_URL = "http://172.20.4.12/monitor/source/getBoradband";
    private static final String RES_URL = "http://127.0.0.1:8081/source/getBoradband";


    public String getName() {
        return "资源系统用户信息查询";
    }

    public String getDesciption() {
        return "";
    }

    public int getVersion() {
        return 0;
    }

    public Attr[] getInAttrs() {
        Attr[] in = new Attr[1];
        in[0] = new Attr("accesscode", "通用账号", AttrType.TYPE_String, true);
        return in;
    }

    public Attr[] getOutAttrs() {
        Attr[] out = new Attr[39];
        out[0] = new Attr("flag", "操作是否成功，1：成功，0：失败", AttrType.TYPE_Int, true);
        out[1] = new Attr("log", "日志文件", AttrType.TYPE_String, true);
 /*
                    "ywhm": "5760X100763",
                        "newsn": "5765SN22243117",
                        "oldsn": null,
                        "khmc": "王小林",
                        "zt": "归档",
                        "pm": "二平面",
                        "xl": "FTTH线路",
                        "jrlx": "光纤",
                        "jx": "4339(椒江OLT局)",
                        "vpi": null,
                        "vci": null,
                        "dk": "T椒江轮渡路/华为E8-C-5765SN22243117/3",
                        "dksl": null,
                        "sswy": "T椒江轮渡路/华为E8-C-5765SN22243117",
                        "sbipdz": null,
                        "oltname": "椒江-OLT-轮渡路-HWMA5680T-9(GFTTH)",
                        "oltip": "10.133.40.133",
                        "oltpz": "椒江-OLT-轮渡路-HWMA5680T-9(GFTTH)",
                        "ponpzmc": "椒江-OLT-轮渡路-HWMA5680T-9(GFTTH)/09/3/12",
                        "ponname": null,
                        "ponpzbm": "JJLDLJFMA5680T-9(GPONFTTH)/09/3/12",
                        "ponbm": "12",
                        "kdnc": "204",
                        "tvnc": "1704",
                        "kdwc": "443",
                        "tvwc": "1943",
                        "wlhm": null,
                        "dh": null,
                        "ch": null,
                        "dkpzmc": null,
                        "dkpzbm": null
                     */
        out[2] = new Attr("ywhm", "业务号码", AttrType.TYPE_String, true);
        out[3] = new Attr("newsn", "新SN号", AttrType.TYPE_String, true);
        out[4] = new Attr("oldsn", "旧SN号", AttrType.TYPE_String, true);
        out[5] = new Attr("khmc", "客户名称", AttrType.TYPE_String, true);
        out[6] = new Attr("zt", "状态", AttrType.TYPE_String, true);
        out[7] = new Attr("pm", "平面", AttrType.TYPE_String, true);
        out[8] = new Attr("xl", "线路", AttrType.TYPE_String, true);
        out[9] = new Attr("jrlx", "接入类型", AttrType.TYPE_String, true);
        out[10] = new Attr("jx", "局向", AttrType.TYPE_String, true);
        out[11] = new Attr("vpi", "VPI", AttrType.TYPE_String, true);
        out[12] = new Attr("vci", "VCI", AttrType.TYPE_String, true);
        out[13] = new Attr("dk", "端口", AttrType.TYPE_String, true);
        out[14] = new Attr("dksl", "端口速率", AttrType.TYPE_String, true);
        out[15] = new Attr("sswy", "所属网元", AttrType.TYPE_String, true);
        out[16] = new Attr("sbipdz", "设备IP地址", AttrType.TYPE_String, true);
        out[17] = new Attr("oltname", "OLT名称", AttrType.TYPE_String, true);
        out[18] = new Attr("oltip", "OLT_IP", AttrType.TYPE_String, true);
        out[19] = new Attr("oltpz", "OLT拼装", AttrType.TYPE_String, true);
        out[20] = new Attr("ponpzmc", "PON口拼装名称", AttrType.TYPE_String, true);
        out[21] = new Attr("ponname", "PON口名称", AttrType.TYPE_String, true);
        out[22] = new Attr("ponpzbm", "PON口拼装编码", AttrType.TYPE_String, true);
        out[23] = new Attr("ponbm", "PON口编码", AttrType.TYPE_String, true);
        out[24] = new Attr("kdnc", "宽带内层", AttrType.TYPE_String, true);
        out[25] = new Attr("tvnc", "TV内层", AttrType.TYPE_String, true);
        out[26] = new Attr("kdwc", "宽带外层", AttrType.TYPE_String, true);
        out[27] = new Attr("tvwc", "TV外层", AttrType.TYPE_String, true);
        out[28] = new Attr("wlhm", "物理号码", AttrType.TYPE_String, true);
        out[29] = new Attr("dh", "短号", AttrType.TYPE_String, true);
        out[30] = new Attr("ch", "长号", AttrType.TYPE_String, true);
        out[31] = new Attr("dkpzmc", "端口拼装名称", AttrType.TYPE_String, true);
        out[32] = new Attr("dkpzbm", "端口拼装编码", AttrType.TYPE_String, true);
        out[32] = new Attr("account", "宽带帐号", AttrType.TYPE_String, true);
        out[33] = new Attr("itvaccount", "ITV账号", AttrType.TYPE_String, true);
        out[34] = new Attr("itvywhm", "ITV业务号码", AttrType.TYPE_String, true);
        out[35] = new Attr("ghywhm", "固话业务号码", AttrType.TYPE_String, true);
        out[36] = new Attr("ghwlhm", "固话物理号码", AttrType.TYPE_String, true);
        out[37] = new Attr("ghdk", "固话端口", AttrType.TYPE_String, true);
        out[38] = new Attr("ponid", "PON口ID", AttrType.TYPE_String, true);
        return out;
    }

    public Map<String, Object> init(Map<String, Object> data) {
         String account = (String)data.get("accesscode");
         if(StringUtils.isNotBlank(account)){
             return getRES(account);
         }else {
             Map<String,Object> reply = new HashMap<String,Object>();
             reply.put("flag","0");
             reply.put("log", "网元能力入参数有误");
             return reply;
         }
    }

    /**
     * 查询接口
     * @param account 用户账号
     * @return
     */
    private Map<String,Object> getRES(String account){
        String resp = null;
        Map<String,Object> reply = new HashMap<String,Object>();
        try {
                //System.out.println(doPost("http://127.0.0.1:8080/sources/getBoradband", params, "utf-8"));
            resp = doPost(RES_URL,account);
            //resp = HttpKit.post(RES_URL,"accesscode="+account);
            if(StringUtils.isNotBlank(resp)){
                if(resp.equals("404")){
                    reply.put("flag","0");
                    reply.put("log", "资源请求服务器失败无响应");
                    return reply;
                }

                JSONObject jsonOut = JSON.parseObject(resp);
                if(jsonOut.getBooleanValue("success")) {
                    JSONArray arrayOut = jsonOut.getJSONArray("data");
                    String log = "";
                    String flag = "0";
                    for (int i=0;i<arrayOut.size();i++){
                        JSONObject object = arrayOut.getJSONObject(i);

                        if (object.get("object") == null) {
                            object = object.getJSONArray("children").getJSONObject(0).getJSONObject("object");
                        } else {
                            object = object.getJSONObject("object");
                        }

                        //取得资源对象 object
                        log += object.toJSONString();

                        if(StringUtils.isBlank(((String)reply.get("newsn"))))
                            reply.put("newsn", object.getString("newsn")==null ? "" : object.getString("newsn"));
                        if(StringUtils.isBlank(((String)reply.get("oldsn"))))
                            reply.put("oldsn", object.getString("oldsn")==null ? "" : object.getString("oldsn"));
                        if(StringUtils.isBlank(((String)reply.get("khmc"))))
                            reply.put("khmc", object.getString("khmc")==null ? "" : object.getString("khmc"));
                        if(StringUtils.isBlank(((String)reply.get("zt"))))
                            reply.put("zt", object.getString("zt") == null ? "" : object.getString("zt"));
                        if(StringUtils.isBlank(((String)reply.get("pm"))))
                            reply.put("pm", object.getString("pm") == null ? "" : object.getString("pm"));
                        if(StringUtils.isBlank(((String)reply.get("xl"))))
                            reply.put("xl", object.getString("xl") == null ? "" : object.getString("xl"));
                        if(StringUtils.isBlank(((String)reply.get("jrlx"))))
                            reply.put("jrlx", object.getString("jrlx") == null ? "" : object.getString("jrlx"));
                        if(StringUtils.isBlank(((String)reply.get("jx"))))
                            reply.put("jx", object.getString("jx") == null ? "" : object.getString("jx"));
                        if(StringUtils.isBlank(((String)reply.get("vpi"))))
                            reply.put("vpi", object.getString("vpi") == null ? "" : object.getString("vpi"));
                        if(StringUtils.isBlank(((String)reply.get("vci"))))
                            reply.put("vci", object.getString("vci") == null ? "" : object.getString("vci"));
                        if(StringUtils.isBlank(((String)reply.get("dksl"))))
                            reply.put("dksl", object.getString("dksl") == null ? "" : object.getString("dksl"));
                        if(StringUtils.isBlank(((String)reply.get("sswy"))))
                            reply.put("sswy", object.getString("sswy") == null ? "" : object.getString("sswy"));
                        if(StringUtils.isBlank(((String)reply.get("sbipdz"))))
                            reply.put("sbipdz", object.getString("sbipdz") == null ? "" : object.getString("sbipdz"));
                        if(StringUtils.isBlank(((String)reply.get("oltname"))))
                            reply.put("oltname", object.getString("oltname") == null ? "" : object.getString("oltname"));
                        if(StringUtils.isBlank(((String)reply.get("oltip"))))
                            reply.put("oltip", object.getString("oltip") == null ? "" : object.getString("oltip"));
                        if(StringUtils.isBlank(((String)reply.get("oltpz"))))
                            reply.put("oltpz", object.getString("oltpz") == null ? "" : object.getString("oltpz"));
                        if(StringUtils.isBlank(((String)reply.get("ponpzmc"))))
                            reply.put("ponpzmc", object.getString("ponpzmc") == null ? "" : object.getString("ponpzmc"));
                        if(StringUtils.isBlank(((String)reply.get("ponname"))))
                            reply.put("ponname", object.getString("ponname") == null ? "" : object.getString("ponname"));
                        if(StringUtils.isBlank(((String)reply.get("ponpzbm")))){
                            String pon = object.getString("ponpzbm");
                            if(StringUtils.isNotBlank(pon)){
                                reply.put("ponpzbm", pon);
                                String list[] = pon.split("/");
                                if(list.length==4){
                                    //System.out.println("NA-0-"+list[1]+"-"+list[2]);
                                    if(!list[2].equals("NA")){
                                        list[2]=String.valueOf(Integer.parseInt(list[2]));
                                    }
                                    if(!list[3].equals("NA")){
                                        list[3]=String.valueOf(Integer.parseInt(list[3]));
                                    }
                                    reply.put("ponid","NA-0-"+list[2]+"-"+list[3]);
                                }else if(reply.get("ponid")==null){
                                    reply.put("ponid","");
                                }
                            }
                        }


                        if(StringUtils.isBlank(((String)reply.get("ponbm"))))
                            reply.put("ponbm", object.getString("ponbm") == null ? "" : object.getString("ponbm"));
                        if(StringUtils.isBlank(((String)reply.get("kdnc"))))
                            reply.put("kdnc", object.getString("kdnc") == null ? "" : object.getString("kdnc"));
                        if(StringUtils.isBlank(((String)reply.get("tvnc"))))
                            reply.put("tvnc", object.getString("tvnc") == null ? "" : object.getString("tvnc"));
                        if(StringUtils.isBlank(((String)reply.get("kdwc"))))
                            reply.put("kdwc", object.getString("kdwc") == null ? "" : object.getString("kdwc"));
                        if(StringUtils.isBlank(((String)reply.get("tvwc"))))
                            reply.put("tvwc", object.getString("tvwc") == null ? "" : object.getString("tvwc"));

                        if(StringUtils.isBlank(((String)reply.get("dh"))))
                            reply.put("dh", object.getString("dh") == null ? "" : object.getString("dh"));
                        if(StringUtils.isBlank(((String)reply.get("ch"))))
                            reply.put("ch", object.getString("ch") == null ? "" : object.getString("ch"));
                        if(StringUtils.isBlank(((String)reply.get("dkpzmc"))))
                            reply.put("dkpzmc", object.getString("dkpzmc") == null ? "" : object.getString("dkpzmc"));
                        if(StringUtils.isBlank(((String)reply.get("dkpzbm"))))
                            reply.put("dkpzbm", object.getString("dkpzbm") == null ? "" : object.getString("dkpzbm"));

                        if(arrayOut.getJSONObject(i).getInteger("id")==51) {
                            if(StringUtils.isBlank(((String)reply.get("itvaccount"))))
                                if(object.getString("account") == null){
                                    reply.put("itvaccount", "");
                                }else{
                                    reply.put("itvaccount", object.getString("account").split("@")[0]);
                                }
                            if(StringUtils.isBlank(((String)reply.get("itvywhm"))))
                                reply.put("itvywhm", object.getString("ywhm") == null ? "" : object.getString("ywhm"));
                            if(StringUtils.isBlank(((String)reply.get("dk"))))
                                reply.put("dk", object.getString("dk") == null ? "" : object.getString("dk"));
                            if(StringUtils.isBlank(((String)reply.get("wlhm"))))
                                reply.put("wlhm", object.getString("wlhm") == null ? "" : object.getString("wlhm"));

                        }else if(arrayOut.getJSONObject(i).getInteger("id")==21){//固话
                            if(StringUtils.isBlank(((String)reply.get("ghywhm"))))
                                reply.put("ghywhm", object.getString("ywhm") == null ? "" : object.getString("ywhm"));

                            if(StringUtils.isBlank(((String)reply.get("ghwlhm"))))
                                reply.put("ghwlhm", object.getString("wlhm") == null ? "" : object.getString("wlhm"));

                            if(StringUtils.isBlank(((String)reply.get("ghdk"))))
                                reply.put("ghdk", object.getString("dk") == null ? "" : object.getString("dk"));

                            if(StringUtils.isBlank(((String)reply.get("account"))))
                                reply.put("account", object.getString("account") == null ? "" : object.getString("account"));

                        }else {
                            if(StringUtils.isBlank(((String)reply.get("ywhm"))))
                                reply.put("ywhm", object.getString("ywhm") == null ? "" : object.getString("ywhm"));

                            if(StringUtils.isBlank(((String)reply.get("account"))))
                                reply.put("account", object.getString("account") == null ? "" : object.getString("account"));

                            if(StringUtils.isBlank(((String)reply.get("dk"))))
                                reply.put("dk", object.getString("dk") == null ? "" : object.getString("dk"));

                            if(StringUtils.isBlank(((String)reply.get("wlhm"))))
                                reply.put("wlhm", object.getString("wlhm") == null ? "" : object.getString("wlhm"));
                        }

                        flag = "1";
                    }
                    if(StringUtils.isBlank(((String)reply.get("ghywhm"))))
                        reply.put("ghywhm", "");

                    if(StringUtils.isBlank(((String)reply.get("ghwlhm"))))
                        reply.put("ghwlhm", "");

                    if(StringUtils.isBlank(((String)reply.get("ghdk"))))
                        reply.put("ghdk", "");

                    if(StringUtils.isBlank(((String)reply.get("itvaccount"))))
                        reply.put("itvaccount", "");

                    if(StringUtils.isBlank(((String)reply.get("itvywhm"))))
                        reply.put("itvywhm", "");

                    reply.put("flag", flag);
                    reply.put("log", log);
                    return reply;
                    
                }else {
                    reply.put("flag","0");
                    reply.put("log", "资源服务器返回失败");
                    return reply;
                }
            }else {
                reply.put("flag","0");
                reply.put("log", "资源请求无响应");
                return reply;
            }
        }catch (Exception e) {
            e.printStackTrace();
            reply.put("flag","0");
            reply.put("log", e.toString());
            return reply;
        }
    }


    public static String doPost(String url, String account)throws Exception {
        String html = "";
        HttpClient httpClient = new HttpClient();
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(7000);
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(60000);
        System.out.println(url);
        PostMethod postMethod = new PostMethod(url+"?accesscode="+account);
        postMethod.setRequestHeader("accept", "*/*");
        postMethod.setRequestHeader("connection", "Keep-Alive");
        postMethod.setRequestHeader("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
        postMethod.setRequestHeader("Accept-Language", "zh-cn,zh;q=0.5");
        postMethod.setRequestHeader("Accept-Encoding", "gzip,deflate");
        postMethod.setRequestHeader("Content-Type", "text/html;charset=utf-8");
        // 填入各个表单域的值
        //NameValuePair[] data = { new NameValuePair("accesscode", account) };
        // 将表单的值放入postMethod中
        //postMethod.setRequestBody(data);
        // 执行postMethod
        int statusCode = httpClient.executeMethod(postMethod);
        // HttpClient对于要求接受后继服务的请求，象POST和PUT等不能自动处理转发
        // 301或者302
        if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
            // 从头中取出转向的地址
            Header locationHeader = postMethod.getResponseHeader("location");
            String location = null;
            if (locationHeader != null) {
                location = locationHeader.getValue();
                System.out.println("The page was redirected to:" + location);
            } else {
                System.err.println("Location field value is null.");
            }
            return html;
        }
        // html = postMethod.getResponseBodyAsString();
        if(postMethod.getStatusCode()==404){
            return "404";
        }
        // byte[] responseBody = postMethod.getResponseBody();

        BufferedReader in = new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsStream(), postMethod
                .getResponseCharSet()));
        StringBuffer sb = new StringBuffer();
        int chari;
        while ((chari = in.read()) != -1) {
            sb.append((char) chari);
        }
        html = sb.toString();
        in.close();
        return html;
    }

    public static void main(String[] args) {
        String origin = "{\n" +
                "    \"code\": 0,\n" +
                "    \"msg\": \"失败\",\n" +
                "    \"body\": null,\n" +
                "    \"data\": [\n" +
                "        {\n" +
                "            \"id\": 22,\n" +
                "            \"text\": \"有线宽带\",\n" +
                "            \"iconCls\": null,\n" +
                "            \"sortNo\": null,\n" +
                "            \"isEnabled\": null,\n" +
                "            \"checked\": false,\n" +
                "            \"children\": [\n" +
                "                {\n" +
                "                    \"id\": 0,\n" +
                "                    \"text\": \"15372166672\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"15372166672\",\n" +
                "                        \"ywhm\": \"5761UBD19675721\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23785006/3\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23785006\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/7/05\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/11/01\",\n" +
                "                        \"ponbm\": \"05\",\n" +
                "                        \"kdnc\": \"166\",\n" +
                "                        \"tvnc\": \"1666\",\n" +
                "                        \"kdwc\": \"362\",\n" +
                "                        \"tvwc\": \"1862\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                },\n" +
                "                {\n" +
                "                    \"id\": 1,\n" +
                "                    \"text\": \"15372166672\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"15372166672\",\n" +
                "                        \"ywhm\": \"5761UBD19675721\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23262649/3\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23262649\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/15/07\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/15/07\",\n" +
                "                        \"ponbm\": \"07\",\n" +
                "                        \"kdnc\": \"388\",\n" +
                "                        \"tvnc\": \"1888\",\n" +
                "                        \"kdwc\": \"364\",\n" +
                "                        \"tvwc\": \"1864\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                },\n" +
                "                {\n" +
                "                    \"id\": 2,\n" +
                "                    \"text\": \"15372166672\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"15372166672\",\n" +
                "                        \"ywhm\": \"5761UBD19675721\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23785006/3\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23785006\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/7/05\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/7/05\",\n" +
                "                        \"ponbm\": \"05\",\n" +
                "                        \"kdnc\": \"166\",\n" +
                "                        \"tvnc\": \"1666\",\n" +
                "                        \"kdwc\": \"362\",\n" +
                "                        \"tvwc\": \"1862\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                },\n" +
                "                {\n" +
                "                    \"id\": 3,\n" +
                "                    \"text\": \"15372166672\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"15372166672\",\n" +
                "                        \"ywhm\": \"5761UBD19675721\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23262649/3\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23262649\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/15/07\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/15/07\",\n" +
                "                        \"ponbm\": \"07\",\n" +
                "                        \"kdnc\": \"388\",\n" +
                "                        \"tvnc\": \"1888\",\n" +
                "                        \"kdwc\": \"364\",\n" +
                "                        \"tvwc\": \"1864\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                }\n" +
                "            ],\n" +
                "            \"attributes\": {\n" +
                "                \"product_pid\": \"22\"\n" +
                "            },\n" +
                "            \"object\": null,\n" +
                "            \"expanded\": false,\n" +
                "            \"hidden\": false,\n" +
                "            \"disabled\": false\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\": 51,\n" +
                "            \"text\": \"ITV\",\n" +
                "            \"iconCls\": null,\n" +
                "            \"sortNo\": null,\n" +
                "            \"isEnabled\": null,\n" +
                "            \"checked\": false,\n" +
                "            \"children\": [\n" +
                "                {\n" +
                "                    \"id\": 0,\n" +
                "                    \"text\": \"1576110328536\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"tv1576110328536@itv\",\n" +
                "                        \"ywhm\": \"1576110328536\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23785006/4\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23785006\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/7/05\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/7/05\",\n" +
                "                        \"ponbm\": \"05\",\n" +
                "                        \"kdnc\": \"166\",\n" +
                "                        \"tvnc\": \"1666\",\n" +
                "                        \"kdwc\": \"362\",\n" +
                "                        \"tvwc\": \"1862\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                },\n" +
                "                {\n" +
                "                    \"id\": 1,\n" +
                "                    \"text\": \"1576110328536\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"tv1576110328536@itv\",\n" +
                "                        \"ywhm\": \"1576110328536\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23262649/4\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23262649\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/15/07\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/15/07\",\n" +
                "                        \"ponbm\": \"07\",\n" +
                "                        \"kdnc\": \"388\",\n" +
                "                        \"tvnc\": \"1888\",\n" +
                "                        \"kdwc\": \"364\",\n" +
                "                        \"tvwc\": \"1864\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                },\n" +
                "                {\n" +
                "                    \"id\": 2,\n" +
                "                    \"text\": \"1576110328536\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"tv1576110328536@itv\",\n" +
                "                        \"ywhm\": \"1576110328536\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23785006/4\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23785006\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/7/05\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/7/05\",\n" +
                "                        \"ponbm\": \"05\",\n" +
                "                        \"kdnc\": \"166\",\n" +
                "                        \"tvnc\": \"1666\",\n" +
                "                        \"kdwc\": \"362\",\n" +
                "                        \"tvwc\": \"1862\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                },\n" +
                "                {\n" +
                "                    \"id\": 3,\n" +
                "                    \"text\": \"1576110328536\",\n" +
                "                    \"iconCls\": null,\n" +
                "                    \"sortNo\": null,\n" +
                "                    \"isEnabled\": null,\n" +
                "                    \"checked\": false,\n" +
                "                    \"children\": [],\n" +
                "                    \"attributes\": {},\n" +
                "                    \"object\": {\n" +
                "                        \"account\": \"tv1576110328536@itv\",\n" +
                "                        \"ywhm\": \"1576110328536\",\n" +
                "                        \"newsn\": \"5765SN23785006\",\n" +
                "                        \"oldsn\": \"5765SN23262649\",\n" +
                "                        \"khmc\": \"吴伟芳\",\n" +
                "                        \"zt\": \"在途\",\n" +
                "                        \"pm\": \"二平面\",\n" +
                "                        \"xl\": \"FTTH线路\",\n" +
                "                        \"jrlx\": \"光纤\",\n" +
                "                        \"jx\": \"4796(仙居电信OLT局)\",\n" +
                "                        \"vpi\": null,\n" +
                "                        \"vci\": null,\n" +
                "                        \"dk\": \"仙居新电信楼/中兴E8-C-5765SN23262649/4\",\n" +
                "                        \"dksl\": null,\n" +
                "                        \"sswy\": \"仙居新电信楼/中兴E8-C-5765SN23262649\",\n" +
                "                        \"sbipdz\": null,\n" +
                "                        \"oltname\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"oltip\": \"10.132.16.8\",\n" +
                "                        \"oltpz\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）\",\n" +
                "                        \"ponpzmc\": \"仙居-OLT-电信新大楼-ZTEC300-5（GFTTH）/0/15/07\",\n" +
                "                        \"ponname\": null,\n" +
                "                        \"ponpzbm\": \"XJOLTDXXDLC300-5/0/15/07\",\n" +
                "                        \"ponbm\": \"07\",\n" +
                "                        \"kdnc\": \"388\",\n" +
                "                        \"tvnc\": \"1888\",\n" +
                "                        \"kdwc\": \"364\",\n" +
                "                        \"tvwc\": \"1864\",\n" +
                "                        \"wlhm\": null,\n" +
                "                        \"dh\": null,\n" +
                "                        \"ch\": null,\n" +
                "                        \"dkpzmc\": null,\n" +
                "                        \"dkpzbm\": null\n" +
                "                    },\n" +
                "                    \"expanded\": false,\n" +
                "                    \"hidden\": false,\n" +
                "                    \"disabled\": false\n" +
                "                }\n" +
                "            ],\n" +
                "            \"attributes\": {\n" +
                "                \"product_pid\": \"51\"\n" +
                "            },\n" +
                "            \"object\": null,\n" +
                "            \"expanded\": false,\n" +
                "            \"hidden\": false,\n" +
                "            \"disabled\": false\n" +
                "        }\n" +
                "    ],\n" +
                "    \"success\": true\n" +
                "}";
        Map<String,Object> map = getJson(origin);
        for(Map.Entry<String, Object> entry:map.entrySet()){
            System.out.println(entry.getKey()+"--->"+entry.getValue().toString());
        }

    }

    public static Map<String,Object> getJson(String res){
        JSONObject jsonOut = JSON.parseObject(res);
        Map<String,Object> reply = new HashMap<String,Object>();
        if(jsonOut.getBooleanValue("success")) {
            JSONArray arrayOut = jsonOut.getJSONArray("data");
            String log = "";
            String flag = "0";
            for (int i=0;i<arrayOut.size();i++){
                JSONObject object = arrayOut.getJSONObject(i);

                if (object.get("object") == null) {
                    object = object.getJSONArray("children").getJSONObject(0).getJSONObject("object");
                } else {
                    object = object.getJSONObject("object");
                }

                //取得资源对象 object
                log += object.toJSONString();

                if(StringUtils.isBlank(((String)reply.get("newsn"))))
                    reply.put("newsn", object.getString("newsn")==null ? "" : object.getString("newsn"));
                if(StringUtils.isBlank(((String)reply.get("oldsn"))))
                    reply.put("oldsn", object.getString("oldsn")==null ? "" : object.getString("oldsn"));
                if(StringUtils.isBlank(((String)reply.get("khmc"))))
                    reply.put("khmc", object.getString("khmc")==null ? "" : object.getString("khmc"));
                if(StringUtils.isBlank(((String)reply.get("zt"))))
                    reply.put("zt", object.getString("zt") == null ? "" : object.getString("zt"));
                if(StringUtils.isBlank(((String)reply.get("pm"))))
                    reply.put("pm", object.getString("pm") == null ? "" : object.getString("pm"));
                if(StringUtils.isBlank(((String)reply.get("xl"))))
                    reply.put("xl", object.getString("xl") == null ? "" : object.getString("xl"));
                if(StringUtils.isBlank(((String)reply.get("jrlx"))))
                    reply.put("jrlx", object.getString("jrlx") == null ? "" : object.getString("jrlx"));
                if(StringUtils.isBlank(((String)reply.get("jx"))))
                    reply.put("jx", object.getString("jx") == null ? "" : object.getString("jx"));
                if(StringUtils.isBlank(((String)reply.get("vpi"))))
                    reply.put("vpi", object.getString("vpi") == null ? "" : object.getString("vpi"));
                if(StringUtils.isBlank(((String)reply.get("vci"))))
                    reply.put("vci", object.getString("vci") == null ? "" : object.getString("vci"));
                if(StringUtils.isBlank(((String)reply.get("dksl"))))
                    reply.put("dksl", object.getString("dksl") == null ? "" : object.getString("dksl"));
                if(StringUtils.isBlank(((String)reply.get("sswy"))))
                    reply.put("sswy", object.getString("sswy") == null ? "" : object.getString("sswy"));
                if(StringUtils.isBlank(((String)reply.get("sbipdz"))))
                    reply.put("sbipdz", object.getString("sbipdz") == null ? "" : object.getString("sbipdz"));
                if(StringUtils.isBlank(((String)reply.get("oltname"))))
                    reply.put("oltname", object.getString("oltname") == null ? "" : object.getString("oltname"));
                if(StringUtils.isBlank(((String)reply.get("oltip"))))
                    reply.put("oltip", object.getString("oltip") == null ? "" : object.getString("oltip"));
                if(StringUtils.isBlank(((String)reply.get("oltpz"))))
                    reply.put("oltpz", object.getString("oltpz") == null ? "" : object.getString("oltpz"));
                if(StringUtils.isBlank(((String)reply.get("ponpzmc"))))
                    reply.put("ponpzmc", object.getString("ponpzmc") == null ? "" : object.getString("ponpzmc"));
                if(StringUtils.isBlank(((String)reply.get("ponname"))))
                    reply.put("ponname", object.getString("ponname") == null ? "" : object.getString("ponname"));

                if(StringUtils.isBlank(((String)reply.get("ponpzbm")))){
                    String pon = object.getString("ponpzbm");
                    if(StringUtils.isNotBlank(pon)){
                        reply.put("ponpzbm", pon);
                        String list[] = pon.split("/");
                        if(list.length==4){
                            //System.out.println("NA-0-"+list[1]+"-"+list[2]);
                            if(!list[2].equals("NA")){
                                list[2]=String.valueOf(Integer.parseInt(list[2]));
                            }
                            if(!list[3].equals("NA")){
                                list[3]=String.valueOf(Integer.parseInt(list[3]));
                            }
                            reply.put("ponid","NA-0-"+list[2]+"-"+list[3]);
                            System.out.println("ponid******************"+"NA-0-"+list[2]+"-"+list[3]);
                        }else if(reply.get("ponid")==null){
                            reply.put("ponid","");
                        }
                    }
                }


                if(StringUtils.isBlank(((String)reply.get("ponbm"))))
                    reply.put("ponbm", object.getString("ponbm") == null ? "" : object.getString("ponbm"));
                if(StringUtils.isBlank(((String)reply.get("kdnc"))))
                    reply.put("kdnc", object.getString("kdnc") == null ? "" : object.getString("kdnc"));
                if(StringUtils.isBlank(((String)reply.get("tvnc"))))
                    reply.put("tvnc", object.getString("tvnc") == null ? "" : object.getString("tvnc"));
                if(StringUtils.isBlank(((String)reply.get("kdwc"))))
                    reply.put("kdwc", object.getString("kdwc") == null ? "" : object.getString("kdwc"));
                if(StringUtils.isBlank(((String)reply.get("tvwc"))))
                    reply.put("tvwc", object.getString("tvwc") == null ? "" : object.getString("tvwc"));

                if(StringUtils.isBlank(((String)reply.get("dh"))))
                    reply.put("dh", object.getString("dh") == null ? "" : object.getString("dh"));
                if(StringUtils.isBlank(((String)reply.get("ch"))))
                    reply.put("ch", object.getString("ch") == null ? "" : object.getString("ch"));
                if(StringUtils.isBlank(((String)reply.get("dkpzmc"))))
                    reply.put("dkpzmc", object.getString("dkpzmc") == null ? "" : object.getString("dkpzmc"));
                if(StringUtils.isBlank(((String)reply.get("dkpzbm"))))
                    reply.put("dkpzbm", object.getString("dkpzbm") == null ? "" : object.getString("dkpzbm"));

                if(arrayOut.getJSONObject(i).getInteger("id")==51) {
                    if(StringUtils.isBlank(((String)reply.get("itvaccount"))))
                        if(object.getString("account") == null){
                            reply.put("itvaccount", "");
                        }else{
                            reply.put("itvaccount", object.getString("account").split("@")[0]);
                        }

                    if(StringUtils.isBlank(((String)reply.get("itywhm"))))
                        reply.put("itvywhm", object.getString("vywhm") == null ? "" : object.getString("vywhm"));

                    if(StringUtils.isBlank(((String)reply.get("dk"))))
                        reply.put("dk", object.getString("dk") == null ? "" : object.getString("dk"));

                    if(StringUtils.isBlank(((String)reply.get("wlhm"))))
                        reply.put("wlhm", object.getString("wlhm") == null ? "" : object.getString("wlhm"));

                }else if(arrayOut.getJSONObject(i).getInteger("id")==21){//固话
                    if(StringUtils.isBlank(((String)reply.get("ghywhm"))))
                        reply.put("ghywhm", object.getString("ywhm") == null ? "" : object.getString("ywhm"));

                    if(StringUtils.isBlank(((String)reply.get("ghwlhm"))))
                        reply.put("ghwlhm", object.getString("wlhm") == null ? "" : object.getString("wlhm"));

                    if(StringUtils.isBlank(((String)reply.get("ghdk"))))
                        reply.put("ghdk", object.getString("dk") == null ? "" : object.getString("dk"));

                    if(StringUtils.isBlank(((String)reply.get("account"))))
                        reply.put("account", object.getString("account") == null ? "" : object.getString("account"));

                }else {
                    if(StringUtils.isBlank(((String)reply.get("ywhm"))))
                        reply.put("ywhm", object.getString("ywhm") == null ? "" : object.getString("ywhm"));

                    if(StringUtils.isBlank(((String)reply.get("account"))))
                        reply.put("account", object.getString("account") == null ? "" : object.getString("account"));

                    if(StringUtils.isBlank(((String)reply.get("dk"))))
                        reply.put("dk", object.getString("dk") == null ? "" : object.getString("dk"));

                    if(StringUtils.isBlank(((String)reply.get("wlhm"))))
                        reply.put("wlhm", object.getString("wlhm") == null ? "" : object.getString("wlhm"));
                }

                flag = "1";
            }
            if(StringUtils.isBlank(((String)reply.get("ghywhm"))))
                reply.put("ghywhm", "");

            if(StringUtils.isBlank(((String)reply.get("ghwlhm"))))
                reply.put("ghwlhm", "");

            if(StringUtils.isBlank(((String)reply.get("ghdk"))))
                reply.put("ghdk", "");

            if(StringUtils.isBlank(((String)reply.get("itvaccount"))))
                reply.put("itvaccount", "");

            if(StringUtils.isBlank(((String)reply.get("itvywhm"))))
                reply.put("itvywhm", "");

            reply.put("flag", flag);
            reply.put("log", log);
            return reply;
        }else {
            reply.put("flag","0");
            reply.put("log", "资源服务器返回失败");
            return reply;
        }
    }

}
